﻿#region Header

/***************************************************************************
Author : Krishan Kaliraman (www.sharedwith.me)  Date: 1 Aug 2012
***************************************************************************/

#endregion Header 

namespace Common
{
    using System;

    using Microsoft.TeamFoundation.WorkItemTracking.Client;

    public static class Extensions
    {
        #region Methods

        public static bool IsDisplayable(this Field field, int revision)
        {
            if (field.FieldDefinition == null) return false;

            switch ((CoreField)field.Id)
            {
                case CoreField.History:
                case CoreField.ChangedDate:
                case CoreField.RevisedDate:
                case CoreField.ChangedBy:
                case CoreField.AuthorizedAs:
                    return false;

                default:
                    break;
            }

            if (revision == 0)
            {
                if (field.Value == null ||
                   Equals(field.Value, String.Empty) ||
                   Equals(field.Value, 0)) return false;
            }

            return true;
        }

        #endregion Methods
    }
}